#include "StdAfx.h"
#include "binaryds.h"

CBinaryDS::CBinaryDS(void){}

CBinaryDS::~CBinaryDS(void)
{
	Close();
}

BOOL CBinaryDS::Open(CString FileName)
{
	return CFile::Open(FileName,CFile::modeRead|CFile::shareDenyNone);
}

BYTE CBinaryDS::Get()
{
	BYTE c;
	if(CFile::Read(&c,1)!=1) c = 0xFF;
	return c;
}
BYTE CBinaryDS::Look(unsigned int n)
{
	BYTE c;
	ULONGLONG x = CFile::Seek(0,CFile::current);
	if(n) CFile::Seek(n,CFile::current);
	if(CFile::Read(&c,1)!=1) c = 0xFF;
	CFile::Seek(x,CFile::begin);
	return c;
}

BOOL CBinaryDS::IsEOF()
{
	return CFile::Seek(0,CFile::current) == CFile::GetLength();
}

void CBinaryDS::Close()
{
	if(CFile::m_hFile!= INVALID_HANDLE_VALUE) CFile::Close();
}
int CBinaryDS::ReadBlock(PBYTE Target, int n)
{
	return CFile::Read(Target,n);
}
